let numberInput = {
    mounted(el, binding, vnode) {
        el.handler = function (e) {            
            if(/^\d*\.*\d+[eE]{0,1}[+-]?\d*$/.test(e.target.value)){
              return
            }
            switch (binding.value.textType) {
              case 'num':
                // 数字类型
                e.target.value = e.target.value.replace(/\D+/, '');
                break;
              case 'double':
                let regexp = '^\-?\\d*[eE]{0,1}[+-]?(\\.?\\d{0,{{doublePointNum}}})'.replace(/{{doublePointNum}}/g, binding.value.doublePointNum || 2);
                e.target.value = (e.target.value.match(new RegExp(regexp, 'g'))[0]) || '';
                break;
              case 'regExp':
                e.target.value = (e.target.value.match(new RegExp(binding.value.regExp, 'g'))[0]) || '';
                break;
            }
            e.target.dispatchEvent(new Event("input")); //调用input事件使vue v-model绑定更新,下面相同
          };
          el.addEventListener('keyup', el.handler);
    }
  }

export default numberInput

